﻿using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace IRepository
{
    //因为news，typeinfo等都有增删改查一些通用的操作，所以做了base  
    public interface IBaseRepository<TEntity> where TEntity : class, new() //约束是一个类且带构造函数
    {
        Task<bool> CreateAsync(TEntity entity);
        Task<bool> DeleteAsync(int id);
        Task<bool> EditAsync(TEntity entity); 
        Task<TEntity> FindAsync(int id);
        //查询全部数据
        Task<List<TEntity>> QueryAsync();
        //自定义条件查询
        Task<List<TEntity>> QueryAsync(Expression<Func<TEntity,bool>> func);
        //分页查询
        Task<List<TEntity>> QueryAsync(int page,int size,RefAsync<int> total);
        //自定义分页查询
        Task<List<TEntity>> QueryAsync(Expression<Func<TEntity, bool>> func,int page, int size, RefAsync<int> total);
    }
}
